using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PauseMenu : MonoBehaviour
{
    [SerializeField] GameObject pauseUI;
    private bool isPause;

    private void Start() {
        isPause = false;
        pauseUI.SetActive(false);
    }

    private void OnEnable() {
        EventHandler.AddListener(Events.CallPauseMenu, CallPauseMenu);
    }

    private void OnDisable() {
        EventHandler.RemoveListener(Events.CallPauseMenu);
    }

    public void CallPauseMenu()
    {
        isPause = !isPause;
        Time.timeScale = (isPause == true)?0f:1f;
        pauseUI.SetActive(isPause);
    }
}
